<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $this->systemName;?></title>
<link rel="stylesheet" href="<?php echo $this->baseUrl;?>/files/admin/css/main.css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/jquery.js"></script>
<script language="javascript" src="<?php echo $this->baseUrl;?>/files/admin/js/load.js"></script>
</head>

<body>
	<div id="main">
		<div id="topMenu">
			<div id="navigation">当前位置：<a href="<?php echo $this->projectUrl(array('action'=>'index'));?>">选择产品</a> &gt; <span id="focus">菜单列表</span></div>
			<div id="topOtherMenu">
				<select name="productCode" id="productCode" onchange="location.href='<?php echo $this->projectUrl(array('productCode'=>'{productCode}'), NULL, false);?>'.replace('{productCode}', this.value);">
					<option value="">选择产品</option>
<?php
foreach($this->productRows as $row) {
?>
					<option value="<?php echo $row['code'];?>" <?php echo $this->productCode == $row['code'] ? ' selected' : '';?>><?php echo $row['name'];?>（<?php echo $row['code'];?>）</option>		
<?php
}
?>
				</select>
			</div>
		</div>
		<div id="body">
			<div id="content">
				<form id="listForm" name="listForm" method="post" action="">
					<table class="table">
						<tr class="subject">
							<td width="5%" class="checkBoxTd">选择</td>
							<td width="8%">开启</td>
							<td width="8%">ID</td>
							<td>名称</td>
							<td>访问地址</td>
							<td>显示状态</td>
						</tr>
<?php
echo $this->listContent;
?>
					</table>
					<table class="controlTable">
						<tr>
							<td align="left">
								<input type="button" name="all" id="all" value="全选" class="button" onclick="$('.selectCheckBox').attr('checked', true);"/>
								<input type="button" name="cancel" id="cancel" value="取消" class="button" onclick="$('.selectCheckBox').attr('checked', false);"/>
								<input name="menuBtn" type="submit" class="button" id="menuBtn" onclick="return setMenu();" value="设置选中菜单"/></td>
							<td align="right"></td>
						</tr>
					</table>
				</form>
			</div>
		</div>
</div>
<script language="javascript">
function setMenu()
{
	$("#listForm").attr('action', '<?php echo $this->projectUrl(array('action'=>'menu-save', 'productCode'=>$this->productCode, 'backUrl'=>urlencode($this->url())));?>');
}
</script>
<script language="javascript">
$(".selectCheckBox").click(function(){
	var id = $(this).attr('dbid');
	var currParentIds = $(this).attr('parentIds').split(',');
	var checked = this.checked;

	$(".selectCheckBox").each(function(i){
		//设置全部子目录
		var parentIds = $(this).attr('parentIds').split(',');
		for(i = 0; i <= parentIds.length - 1; i++) {
			if (parentIds[i] == id) {
				this.checked = checked;
				break;	
			}
		}

		//设置全部父目录
		if (checked == true) {
			for(i = 0; i <= currParentIds.length - 1; i++) {
				if (currParentIds[i] == $(this).attr('dbid')) {
					this.checked = checked;
					break;	
				}
			}
		}
	});

});
</script>
</body>
</html>